package com.example.library.controller;

import com.example.library.bean.response.Response;
import com.example.library.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/book")
public class BookAPI {

    @Autowired
    private BookService bookService;

    @GetMapping("/getAll")
    public Response getAll() {
        return bookService.getAllBook();
    }

    @GetMapping("/getByType")
    public Response getByType(long typeId) {
        return bookService.getBookByType(typeId);
    }

    @GetMapping("/getDetail")
    public Response getDetail(long bookId,long userId) {
        return bookService.getBookDetail(bookId,userId);
    }

    @GetMapping("/getByCondition")
    public Response getDetail(String condition) {
        return bookService.getBookByCondition(condition);
    }

}
